import requests
from pathlib import Path

def download_map():
    # 获取当前文件所在目录
    current_dir = Path(__file__).parent.parent
    data_dir = current_dir / 'data'
    data_dir.mkdir(exist_ok=True)
    
    # 下载文件
    url = "https://raw.githubusercontent.com/mouday/echarts-map/master/echarts-4.2.1-rc1-map/json/china.json"
    response = requests.get(url)
    
    if response.status_code == 200:
        output_file = data_dir / 'china.geojson'
        with open(output_file, 'wb') as f:
            f.write(response.content)
        print(f"地图文件下载成功！保存在: {output_file}")
    else:
        print(f"下载失败: {response.status_code}")

if __name__ == '__main__':
    download_map() 